#define _CRT_SECURE_NO_WARNINGS  1
#include <stdio.h>

int main()
{
    int n, m = 0;

    int arr1[1000] = { 0 };
    int arr2[1000] = { 0 };
    scanf("%d", &n);
    scanf("%d", &m);
    int i, j = 0;
    for (i = 0; i < n; i++)
    {
        scanf("%d", &arr1[i]);
    }
    for (j = 0; j < m; j++)
    {
        scanf("%d", &arr2[j]);
    }
    i = 0; j = 0;
    while (i < n && j < m)
    {
        if (arr1[i] > arr2[j] )
        {
            printf("%d ", arr2[j]);
            
            j++;
        }
        else
        {
            printf("%d ", arr1[i]);
            i++;
        }
    }
    if (i == n )
    {
        for (; j < m; j++)
        {
            printf("%d ", arr2[j]);
        }
    }
    else
    {
        for (; i < m; i++)
        {
            printf("%d ", arr1[i]);
        }
    }
    return 0;
}